package com.kaili.common.tenant;

import com.alibaba.druid.filter.config.ConfigTools;
import com.alibaba.druid.util.DruidPasswordCallback;
import com.kaili.common.util.CommonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Properties;

public class DbPasswordCallback extends DruidPasswordCallback {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public void setProperties(Properties properties) {
        super.setProperties(properties);

        String password = (String) properties.get("password");

        try {
            setPassword(CommonUtil.druidDecrypt(password).toCharArray());
        } catch (Exception e) {
            logger.error("Druid CommonUtil.druidDecrypt", e);
        }
    }
}